<template>
	<view class="content">
		<view class="courseclick">
			<view class="list" v-for="(item,index) in itemList" :key="index" :class="{ select: selectedIdx === index }"
				@click="selectItem(index)">
				<view class="price">
					<view class="pricea">
						{{item.name}}
					</view>
					<view class="plus">
					</view>
				</view>
			</view>
		</view>
		<view class="information" v-if="selectedIdx==0">
			<view class="commodity">
				<view class=" list" v-for="(item,index) in list" :key="index" @click="toshopinfos(item,item.courseId)">
					<view class="img">
						<image :src="item.goodsImg" mode=""></image>
					</view>
					<view class="text">
						<view class="name">
							<text>{{item.title}}</text>
						</view>
						<view class="introduce">
							<!-- 8章27节 -->
						</view>
						<view class="low">
							<view class="theheart">
								<image src="../../static/311.png" mode=""></image>
							</view>
							<view class="money" v-if="item.price>0">
								<text>￥</text>
								{{item.price}}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="information" v-if="selectedIdx==1">
			<view class="commoditya">
				<view class=" list" v-for="item,index in list" :key="index" @click="toshopinfo(item.goodsId)">
					<view class="img">
						<image :src="item.goodsImg" mode=""></image>
					</view>
					<view class="text">
						<view class="name">
							<text>{{item.title}}</text>
						</view>
						<!-- <view class="introduce">
							吉他参数
						</view> -->
						<view class="low">
							<view class="theheart">
								<view class="hong"> ￥{{item.vipPrice}}
								</view>
								<view class="hui"> ￥{{item.price}}
								</view>
							</view>
							<view class="money">
								<image src="../../static/392.png" mode=""></image>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		getCollectPage
	} from "../../request/api.js"
	export default {
		data() {
			return {
				selectedIdx: 0,
				itemList: [{
					name: '课程'
				}, {
					name: '商品'
				}],
				accordionVal: '',
				accordionVala: '',
				upanddown: 'bottom',
				introduce: -1,
				selectedIdxa: '',
				index: null,
				list: []
			};
		},
		onLoad(options) {},
		onShow() {
			if (this.selectedIdx == 0) {
				this.getCollectPagea('1')
			}
			// this.getCollectPagea('1')
		},
		methods: {
			getCollectPagea(type) {
				getCollectPage({
					type: type,
					memberId: uni.getStorageSync('userInfo').id
				}).then(res => {
					console.log(res);
					this.list = res.result.records
				})
			},
			appear(index) {
				if (this.introduce === index) {
					this.introduce = null;
				} else {
					this.introduce = index;
				}
			},
			toshopinfo(id) {
				uni.navigateTo({
					url: '/pages/classification/goods?id=' + id
					// url: '/pages/goodsinfo/index'
				})
			},
			toshopinfos(item, id) {
				getApp().globalData.details = item
				uni.navigateTo({
					url: '/pages/details/index?courseId=' + id
				})
			},
			selectItem(index) {
				this.selectedIdx = index;
				this.list = []
				if (index == 0) {
					this.getCollectPagea('1')
				}
				if (index == 1) {
					this.getCollectPagea('2')
				}
			},
		},
	};
</script>
<style scoped lang="less">
	.content {
		width: 100%;
		min-height: 100vh;
		box-sizing: border-box;
		// padding: 16rpx;
		// padding-top: 0rpx;
		background: #f6f6f6;
		// padding-top: 20rpx;
		padding-bottom: 250rpx;
	}

	.courseclick {
		padding: 30rpx 16rpx;
		padding-bottom: 0;
		margin-top: 12rpx;
		background-color: #fff;
		display: flex;
		align-items: center;
		justify-content: space-around;
		margin-bottom: 24rpx;

		.list {
			// margin-bottom: 50rpx;
			border-radius: 20rpx;
			padding-bottom: 26rpx;
			display: flex;
			justify-content: space-between;
			// text-align: center;
			font-size: 36rpx;
			margin-right: 36rpx;
			color: #979797;
			font-size: 28rpx;
			font-weight: 700;

			.name {
				color: #333333;
				font-size: 24rpx;
				font-weight: 500;
				padding: 0 8rpx;
			}

			.price {
				position: relative;

				.pricea {}
			}
		}

		.select {
			margin-right: 36rpx;
			color: #333;
			display: flex;
			font-size: 28rpx;
			font-weight: 700;

			.plus {
				width: 40rpx;
				height: 4rpx;
				border-radius: 160rpx;
				background: #ff9d34;
				position: absolute;
				bottom: -15rpx;
				left: 50%;
				transform: translateX(-50%);
			}
		}
	}

	.information {
		padding-top: 0;
		margin: 32rpx;
	}

	.discountul {
		margin-bottom: 20rpx;
		position: relative;

		.usedalready {
			width: 100%;
			height: 100%;
			position: absolute;
			top: 0;
			left: 0;

			.image {
				width: 686rpx;
				height: 206rpx;
			}
		}

		.discountli {
			border-radius: 20rpx;
			background: #ffffff;
			// padding: 30rpx 20rpx 26rpx 24rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.left {
				width: 198rpx;
				height: 206rpx;
				border-radius: 20rpx 0 0 20rpx;
				padding: 30rpx 20rpx 26rpx 24rpx;
				background: rgba(255, 156, 51, 0.2);
				color: #ff9c33;
				text-align: center;

				// margin-right: 32rpx;
				.minus {
					color: #ff9c33;
					font-size: 72rpx;
					font-weight: 700;
					margin-top: 30rpx;
					margin-bottom: 15rpx;

					text {
						color: #ff9c33;
						font-size: 36rpx;
						font-weight: 500;
					}
				}

				.full {
					color: #ff9c33;
					font-size: 28rpx;
					font-weight: 700;
				}
			}

			.right {
				// width: 100%;
				// padding: 30rpx 20rpx 26rpx 24rpx;
				padding-right: 20rpx;

				.fullname {
					color: #333333;
					font-size: 36rpx;
					font-weight: 700;
				}

				.use {
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-top: 8rpx;
					margin-bottom: 22rpx;

					.date {
						color: #333333;
						font-size: 24rpx;
						font-weight: 400;
						margin-right: 28rpx;
					}

					.send {
						width: 138rpx;
						height: 50rpx;
						border-radius: 258rpx;
						background: #ff9c33;
						color: #ffffff;
						text-align: center;
						line-height: 50rpx;
						font-size: 28rpx;
						font-weight: 500;
					}
				}

				.describe {
					.instructions {
						color: #333333;
						font-size: 24rpx;
						font-weight: 400;
					}
				}
			}
		}

		.explanationcontent {
			background: #ffffff;
			padding: 30rpx 20rpx 26rpx 224rpx;
			color: #9e9e9e;
			font-size: 24rpx;
			font-weight: 400;
		}
	}

	.commodity {
		margin-top: 20rpx;

		.list {
			height: 216rpx;
			border-radius: 22rpx;
			background: #ffffff;
			display: flex;
			align-items: center;
			padding: 22rpx 26rpx 28rpx 18rpx;
			box-sizing: border-box;

			.img {
				width: 328rpx;
				height: 166rpx;

				image {
					width: 328rpx;
					height: 166rpx;
				}
			}

			.text {
				margin-left: 20rpx;

				.name {
					width: 288rpx;
					color: #000000;
					font-size: 28rpx;
					font-weight: 700;
					overflow: hidden;
					/* 确保内容超出容器时会被隐藏 */
					white-space: nowrap;
					/* 确保文本在一行内显示，避免换行 */
					text-overflow: ellipsis;

					text {
						overflow: hidden;
						/* 确保内容超出容器时会被隐藏 */
						white-space: nowrap;
						/* 确保文本在一行内显示，避免换行 */
						text-overflow: ellipsis;
					}
				}

				.introduce {
					color: #3333334d;
					font-size: 24rpx;
					font-weight: 500;
					margin-top: 18rpx;
					margin-bottom: 22rpx;
				}

				.low {
					display: flex;
					justify-content: space-between;

					.theheart {
						width: 48rpx;
						height: 48rpx;

						image {
							width: 48rpx;
							height: 48rpx;
						}
					}

					.money {
						color: #d73c38;
						font-size: 36rpx;
						font-weight: 500;

						text {
							color: #d73c38;
							font-size: 24rpx;
							font-weight: 500;
						}
					}
				}
			}
		}
	}

	.commoditya {
		margin-top: 20rpx;

		.list {
			height: 216rpx;
			border-radius: 22rpx;
			background: #ffffff;
			display: flex;
			align-items: center;
			padding: 22rpx 26rpx 28rpx 18rpx;
			box-sizing: border-box;
			border-bottom: 4rpx solid #f6f6f6;

			.img {
				width: 176rpx;
				height: 176rpx;

				image {
					width: 176rpx;
					height: 176rpx;
				}
			}

			.text {
				margin-left: 20rpx;

				.name {
					width: 450rpx;
					color: #000000;
					font-size: 28rpx;
					font-weight: 700;
					// margin: 38rpx 0 26rpx;
					overflow: hidden;
					/* 确保内容超出容器时会被隐藏 */
					white-space: nowrap;
					/* 确保文本在一行内显示，避免换行 */
					text-overflow: ellipsis;

					text {
						overflow: hidden;
						/* 确保内容超出容器时会被隐藏 */
						white-space: nowrap;
						/* 确保文本在一行内显示，避免换行 */
						text-overflow: ellipsis;
					}
				}

				.introduce {
					color: #3333334d;
					font-size: 24rpx;
					font-weight: 500;
					margin-top: 18rpx;
					margin-bottom: 22rpx;
				}

				.low {
					display: flex;
					justify-content: space-between;

					.theheart {
						display: flex;
						align-items: center;

						.hong {
							color: #d73c38;
							font-size: 36rpx;
							font-weight: 500;
							margin-right: 10rpx;
						}

						.hui {
							color: #3333334d;
							font-size: 24rpx;
							font-weight: 400;
							// text-decoration: line-through;
						}
					}

					.money {
						width: 54rpx;
						height: 54rpx;

						image {
							width: 54rpx;
							height: 54rpx;
						}
					}
				}
			}
		}
	}
</style>